{template 'common/header'}


<!-- <script type="text/javascript" src="{php echo $_W['siteroot']}addons/ciyt_ms/resources/js/bootstrap-switch.min.js"></script> -->



<style>


.pm-wrap {
	position: relative;
	overflow: hidden;
	clear: both;
	
}

.pm-ans {
	float: left;
	margin: 10px 0;
	clear: none;
}
.pm-wrap p {
	width: 72px;
	height: 26px;
	margin: 0 10px 0 0;
	font-size: 14px;
	line-height: 26px;
	text-align: right;
}
.switch::after {
	right: auto;

}
.switch input {
	visibility: hidden;	
}
.switch.seleted::before {
	background-color: #428bca;
}
.switch.seleted::after {
	left: auto;
	right: 1px;
	
}

.pm-fl {
	float: left;
}

.pm-bind > div{
	float: left;
	height: 36px;
	line-height: 36px;
}

.pm-bind:after {
	content: '';
	display: block;
	height: 0;
	clear: both;
}

.text1 {
	font-size: 14px;
	margin-right: 12px;
}

.bind_name{
	float: left;
	text-align: 
}

.bind_but {
	width:520px;
	padding-left: 32px;
	text-align: right;
}

.tips {
	width: 520px;
	margin-left: 92px;
	margin-top: 10px;
	margin-bottom: 50px;
	color: #999;
	font-size: 12px;
	text-align: left;
	clear: both;
}

.pm-bind .mybut.btn {
	float: left;
	width: 84px;
	height: 32px;
	margin-top: 3px;
	margin-left: 15px;
	border:none;
	border-radius: 4px;
	background-color: #67adfd;
	color: #fff;
	font-size: 12px;
}
#nicks {
	max-height: 516px;
	overflow-y: scroll;
}
.ssul>li>a,
.dropdown-menu>li>a {
	display: inline-block;
	*display: inline;
	*zoom:1;
}

.ssul>li>a:hover,
.dropdown-menu>li>a:hover {
	color: 333;
	background-color: none;
}

.ssul li:hover,
.dropdown-menu li:hover {
	background-color: #f5f5f5;
	cursor: pointer;
}

.ssgl {
	position: relative;
	top: 3px;
	width: 260px;
	height: 33px;
	margin-right: 4px;
	text-indent: 8px;
}

.pm-fill {
	position: absolute;
	left: 0;
	right: 0;
	top: 0;
	bottom: 0;
	z-index: 1;
}

.ssul {
	float: left;
	min-width: 160px;
	padding: 5px 0;
	margin: 2px 0 0;
	font-size: 14px;
	text-align: left;
	list-style: none;
	background-color: #fff;
	-webkit-background-clip: padding-box;
	background-clip: padding-box;
	border: 1px solid #ccc;
	border: 1px solid rgba(0,0,0,.15);
	border-radius: 4px;
	-webkit-box-shadow: 0 6px 12px rgba(0,0,0,.175);
	box-shadow: 0 6px 12px rgba(0,0,0,.175);
}
.ssul a {
	padding: 3px 20px;
	clear: both;
	font-weight: 400;
	line-height: 1.42857143;
	color: #333;
	white-space: nowrap;
}

</style>


	<div class="url" data-url="{$url_ss}" style="display:none;height:0;overflow:hidden;visibility:hidden;margin:0;padding:0;"></div>
	
	<div class="pm-bind">
		<div class="text1">绑定管理员</div>
		<div class="dropdown">
			<button class="btn btn-default dropdown-toggle bind_but" type="button" id="dropdownMenu1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true" >
				{if $old}
				<img src="{$old['touxiang']}" alt="" width="16" height="16" style="position:absolute;left:10px;top:12px;">
				<div class="bind_name">{$old['nickname']}</div>
				<span class="caret"></span>
				{else}
				<img src="" alt="" width="16" height="16" style="position:absolute;left:10px;top:12px;">
				<div class="bind_name">未设置管理员</div>
				<span class="caret"></span>
				{/if}
			</button>
			<ul id="nicks" class="dropdown-menu" aria-labelledby="dropdownMenu1" style="width:520px;">
				{loop $nicknames $key $value}
				<li style="position:relative;">
					<img src="{$value['avatar']}" alt="" width="16" height="16" style="margin-left:20px;">
					<a href="#">{$value['nickname']}</a>
					<div class="pm-fill" data-name="{$value['nickname']}" data-toux="{$value['avatar']}" data-openid="{$value['openid']}"></div>
				</li>				
				{/loop}
			</ul>
		</div>
		<input type="button" class="mybut btn btn-large btn-primary btn-block" value="搜索管理员" data-toggle="modal" data-target=".sstc">
	</div>

	<p class="tips">*用于商户手机端登录，请先在小程序端“我的”页面给予授权</p>	
	
			


	<div class="panel panel-default">
		<div class="panel-heading">
			<h3 class="panel-title">
				首页编辑设置
			</h3>
		</div>

		<div class="pm-kg pm-wrap">
			<div class="pm-wrap pm-ans">
				<p class="pm-fl">轮播图</p>
				<div class="switch pm-fl sw1" data-gn="sw1">
					<input type="checkbox" checked />
				</div>
			</div>

			<div class="pm-wrap pm-ans">
				<p class="pm-fl">业务介绍</p>
				<div class="switch pm-fl sw2" data-gn="sw2">
					<input type="checkbox" checked />
				</div>
			</div>

			<div class="pm-wrap pm-ans">
				<p class="pm-fl">公司介绍</p>
				<div class="switch pm-fl sw3" data-gn="sw3">
					<input type="checkbox" checked />
				</div>
			</div>

			<div class="pm-wrap pm-ans">
				<p class="pm-fl">产品展示</p>
				<div class="switch pm-fl sw4" data-gn="sw4">
					<input type="checkbox" checked />
				</div>
			</div>
		</div>
	</div>		


	
	<form action="{php echo $this->createWebUrl('basics')}&" method="POST">
		{if $old}
		<input type="hidden" name="openid" value="{$old['openids']}">
		{else}
		<input type="hidden" name="openid" value="">
		{/if}
		{if $old_gn}
		<input type="hidden" name="gn" value="{$old_gn['kg']}">
		{else}
		<input type="hidden" name="gn" value="sw1,sw2,sw3,sw4">
		{/if}
		<button type="submit" class="btn btn-default">保存</button>
		
	</form>




	<!-- Modal -->
	<div class="modal sstc" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
		<div class="modal-dialog" role="document" style="min-width:600px;font-size:18px;text-align:center;">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span id="off" aria-hidden="true">&times;</span></button>
					<h4 class="modal-title" id="myModalLabel">提示</h4>
				</div>
				<div class="modal-body">
					<input class="ssgl" type="text" value="" placeholder="请输入微信昵称/openid" style="padding:2px;" />
					<input type="button" class="mybut btn butss btn-primary" value="搜索" onclick="ss();">					
					<ul class="ssul" style="width:260px;min-height: 38px;"></ul>
				</div>
				<div class="modal-footer">
					<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
				</div>
			</div>
		</div>
	</div>
	


	<script>

		var url_ss = document.getElementsByClassName('url')[0].dataset.url;
		var seleced = document.getElementsByClassName('bind_but');
		var ul = document.getElementById('nicks');
		var sslist = document.getElementsByClassName('ssul')[0];
		var ssgl = document.getElementsByClassName('ssgl')[0];
		var off = document.getElementById('off');
		var post_openid = document.getElementsByName('openid');
		console.log(ssgl);
		ul.onclick = function(ev) {
			console.log(ev);
			console.log('获取到的数据name',ev.target.dataset.name);
			console.log('获取到的数据toux',ev.target.dataset.toux);
			seleced[0].children[0].src = ev.target.dataset.toux;
			seleced[0].children[1].innerText = ev.target.dataset.name;
			post_openid[0].value = ev.target.dataset.openid;
		}
		
		function strToJson(str){ 
			var json = eval('(' + str + ')'); 
			return json; 
		} 

			console.log(ssgl.value);
		function ss() {
			// alert(document.getElementsByClassName('ssgl')[0].value);
			if (ssgl.value != '') {
				$.ajax({
					type: "POST",
					url: url_ss,
					// url: "http://localhost/we7/web/index.php?c=site&a=entry&do=ss&m=ciyt_ms",
					data: "gjz=" + ssgl.value,
					success: function(msg){
						var ssData = strToJson(msg);
						console.log(ssData);
						console.log(typeof(ssData));
				
						var insert = '';
						for (var i = 0; i < ssData.length; i++) {

							insert = insert +  '<li style="position:relative;"><img src="' + ssData[i].avatar + '" alt="" width="16" height="16" style="margin-left:20px;"><a href="#">' + ssData[i].nickname + '</a><div class="pm-fill" data-name="' + ssData[i].nickname + '" data-toux="' + ssData[i].avatar + '" data-openid="' + ssData[i].openid + '"></div></li>';
							
						};
						sslist.innerHTML = insert;

						sslist.onclick = function(ev) {
							seleced[0].children[0].src = ev.target.dataset.toux;
							seleced[0].children[1].innerText = ev.target.dataset.name;
							post_openid[0].value = ev.target.dataset.openid;
							off.click();

							ssgl.value = '';
							insert = '';
							sslist.innerHTML = insert;
							sslist.onclick = '';
						}



						
					}
				});
			};
			
		}



	
		

		

		

	</script>

<script type="text/javascript" src="{php echo $_W['siteroot']}addons/ciyt_ms/resources/js/aaa.js"></script>
{template 'common/footer'}
